<?php

	require_once './model/RegisterHandler.php';
	require_once './view/RegisterView.php';

	class RegisterController {
		
		public function DoControll(RegisterHandler $regInstance) {
			
			$message = "";
			$lView = new LoginView();
			$view = new RegisterView();			

			//Om man tryckt på confirm-knappen.
			if ($view->ConfButton() == true) {
					
				//KOllar så att allt stämmer, så visas rätt-meddelande.
				if ($regInstance->RegisterUser($view->UserName(), $view->PassWord(), $view->PassWordTwo()) == true) {
					return $view->Success();
				}
				else if ($regInstance->RegisterUser($view->UserName(), $view->PassWord(), $view->PassWordTwo()) == false) {
					$message = $regInstance->error;
				}	
			}
			
			return $message . $view->NewUser();
		}
	}
